package com.hz.qs.utils;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;

@Data
@Builder
@ApiModel("api通用返回数据")
public class RestResult<T> {

    private static final long serialVersionUID = -3821914432791782552L;

    @ApiModelProperty(value = "成功失败标志", name = "success")
    private Boolean success;
    @ApiModelProperty(value = "返回消息", name = "msg")
    private String msg;
    @ApiModelProperty(value = "返回数据模型", name = "result")
    private Object result;

    public static RestResult successResult(Object result) {
        return RestResult.builder().success(Boolean.TRUE).msg("success").result(result).build();
    }

    public static RestResult failResult(String msg, Object result) {
        return RestResult.builder().success(Boolean.FALSE).msg(msg).result(result).build();
    }
}
